<template>
  <div class="app-container">
    <el-card class="content-edit">
      <div slot="header">小程序功能设置</div>
      <el-divider>司机端</el-divider>
      <el-form ref="form" :model="form" label-width="160px">
        <el-form-item label="上下线状态">
          <el-radio-group v-model="form['onlineStatus']" @change="onSubmit">
            <el-radio label="1">开启</el-radio>
            <el-radio label="0">关闭</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="我的钱包">
          <el-radio-group v-model="form['walletStatus']" @change="onSubmit">
            <el-radio label="1">开启</el-radio>
            <el-radio label="0">关闭</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        form: {
          onlineStatus: '1',
          walletStatus: '1'
        }
      }
    },
    mounted(){
      this.loadData();
    },
    methods: {
      loadData() {
        (async () => {
          const result = await this.$service.applicationGetPluginConfig();
          if (result.code === 0) {
            Object.assign(this.form, result.data || {})
          }
        })();
      },
      // 提交
      onSubmit() {
        (async () => {
          const params = Object.assign({}, this.form);
          const result = await this.$service.applicationSavePluginConfig(params);
          if (result.code === 0) {
            this.$message.success('操作成功~');
          } else {
            this.$message.error(result.msg);
          }
        })();
      }
    }
  }
</script>

